<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>作业12</title>
    <script>
        /*
        将"i love javascript very much"的每个单词的第一个字母，变为大写。
        */

        function toCap(str) {
            var arr = str.split(" ");
            for(var i=0; i<arr.length; i++){
                var arr2 = arr[i].split("");
                arr2.splice(0,1,arr2[0].toUpperCase());
                arr[i] = arr2.join("");
            }
            
            return arr.join(" ");
        }

        console.log(toCap("i love javascript very much"));


    </script>
</head>
<body>
    
</body>
</html>